package com.woniu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.entity.PageData;
import com.woniu.entity.dto.QueryCarDTO;
import com.woniu.entity.vo.OrderByIdVO;
import com.woniu.entity.vo.QueryCarByIdVO;
import com.woniu.entity.vo.QueryCarVO;
import com.woniu.entity.vo.UserCarVO;
import com.woniu.mapper.CarMapper;
import com.woniu.pojo.Car;
import com.woniu.pojo.User;
import com.woniu.service.CarService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import javax.annotation.Resource;

/**
* @author Ma.Lei
* @description 针对表【t_car】的数据库操作Service实现
* @createDate 2022-12-16 23:27:39
*/
@Service
public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements CarService {

    @Autowired(required = false)
    private CarMapper carMapper;
    @Override
    public PageData listSearch(Integer currentPage, Integer pageSize, QueryCarDTO queryCarDTO) {
        PageHelper.startPage(currentPage,pageSize);
        List<QueryCarVO> queryCarVOList = carMapper.listSearch(queryCarDTO);
        PageInfo<QueryCarVO> queryCarVOPageInfo = new PageInfo<>(queryCarVOList);
        return new PageData(queryCarVOPageInfo.getTotal(),queryCarVOPageInfo.getList() );
    }

    @Override
    public int disabledCar(String id, Integer status) {
        return carMapper.disabledCar(id,status);
    }

    @Override
    public List<QueryCarByIdVO> listCarByUserId(String id) {
        List<QueryCarByIdVO> carList = carMapper.listCarByUserId(id);
        return carList;
    }

    @Override
    public List<OrderByIdVO> listOrderByCarId(String id) {
        return carMapper.listOrderByCarId(id);
    }


    @Override
    public List<UserCarVO> getByNumber(String id) {
        return carMapper.getByNumber(id);
    }

    @Override
    public Boolean deleteCar(String carNumber, String id) {
        return carMapper.deleteCar(carNumber,id);
    }

    @Override
    public Car selectCarByNum(String id, String carNum) {
        return carMapper.selectCarByNum(id,carNum);
    }


    @Override
    public Car getByCarNumber(String carNum) {
        return carMapper.getByCarNumber(carNum);
    }
    @Override
    public String getIdByNumber(String carNumber) {
        String carId = carMapper.getIdByNumber(carNumber);
        return carId;
    }
}




